package top.yueyazhui.vhr.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yueyazhui.vhr.mapper.DepartmentMapper;
import top.yueyazhui.vhr.model.Department;

import java.util.List;

@Service
public class DepartmentService {

    @Autowired
    DepartmentMapper departmentMapper;

    public List<Department> getAll() {
        return departmentMapper.getAllByParentId(-1);
    }

    public void insert(Department department) {
        department.setEnabled(true);
        departmentMapper.insertRecord(department);
    }

    public void delete(Department department) {
        departmentMapper.delete(department);
    }

    public List<Department> getAllWithOutChildren() {
        return departmentMapper.getAll();
    }
}
